/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.senac.academicnet.model;

import br.com.senac.academicnet.model.entidades.TurmaVO;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.List;

public class TurmaBO {

    public static void incluir(TurmaVO turma) throws Exception {
        TurmaDAO.incluir(turma);
    }

    public static void alterar(TurmaVO turma) throws Exception {
        TurmaDAO.alterar(turma);
    }

    public static void deletar(TurmaVO turma) throws Exception {
        TurmaDAO.deletar(turma);
    }
    
    public static void deletarTudo() throws Exception {
        TurmaDAO.deletarTudo();
    }

    
    public static List<TurmaVO> getTurmas() throws Exception {
        return TurmaDAO.getTurmas();
    }
    
    public static TurmaVO getTurma(int codigo) throws Exception {
        return TurmaDAO.getTurma(codigo);
    }
    
    public static void exportarCSV(String arquivo) throws Exception {
        FileWriter writer = new FileWriter(arquivo);
        BufferedWriter bw = new BufferedWriter(writer);
        try {
            List<TurmaVO> turmas = getTurmas();

            bw.append("Codigo;Nome;Curso;\n");
            for (TurmaVO turma : turmas) {
                bw.append(turma.toString() + "\n");
            }

        } catch (Exception e) {
            throw e;
        } finally {
            bw.close();
        }
    }
}